package controller;

import cn.hutool.core.lang.Singleton;
import com.tulskiy.keymaster.common.Provider;
import lombok.extern.slf4j.Slf4j;
import service.WakeOrHideService;

import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;

/**
 * @author zhangpeiwen
 * @since 2020/10/2
 */
@Slf4j
public class ShortcutController {
    private WakeOrHideService wakeOrHideService = Singleton.get(WakeOrHideService.class);

    public void bindGlobalWakeOrHideShortcut(KeyStroke keyStroke){
        // 用swing的queue
        Provider provider = Provider.getCurrentProvider(true);
        // 绑定快捷键
        provider.register(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
                x-> wakeOrHideService.wakeOrHide());
    }

}
